<template>
  <div class="solution-detail">
    <div>
      <BasicBusiness ref="basicBusinessRef" />
    </div>
    <div style="padding: 50px">
      <Step ref="stepRef" />
    </div>
    <el-form
      ref="elForm"
      :model="formData"
      :rules="rules"
      size="mini"
      label-width="150px"
    >
      <el-form-item label="邀请询价" prop="inviteEnquiry">
        <el-input
          v-model="formData.inviteEnquiry"
          placeholder="请输入邀请询价"
          clearable
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="合作伙伴" prop="partner">
        <el-input
          v-model="formData.partner"
          placeholder="请输入合作伙伴"
          clearable
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="公开比选" prop="publicCompare">
        <el-input
          v-model="formData.publicCompare"
          placeholder="请输入公开比选"
          clearable
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="公开招标" prop="publicTenders">
        <el-input
          v-model="formData.publicTenders"
          placeholder="请输入公开招标"
          clearable
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item size="mini">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import BasicBusiness from "@/views/components/business/BasicBusiness.vue";
import Step from "@/views/components/business/Step.vue";
import { getProjectDetail, downProcurementReady } from "@/api/project/index";
export default {
  components: { BasicBusiness, Step },
  props: [],
  data() {
    return {
      formData: {
        inviteEnquiry: undefined,
        partner: undefined,
        publicCompare: undefined,
        publicTenders: undefined,
      },
      rules: {
        inviteEnquiry: [
          {
            required: true,
            message: "请输入邀请询价",
            trigger: "blur",
          },
        ],
        partner: [
          {
            required: true,
            message: "请输入合作伙伴",
            trigger: "blur",
          },
        ],
        publicCompare: [
          {
            required: true,
            message: "请输入公开比选",
            trigger: "blur",
          },
        ],
        publicTenders: [
          {
            required: true,
            message: "请输入公开招标",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {
    boId() {
      return this.$route.query.boId;
    },
    projectId() {
      return this.$route.query.projectId;
    },
  },
  watch: {},
  created() {},
  mounted() {
    this.loadData();
  },
  methods: {
    loadData() {
      this.$refs.basicBusinessRef.loadData(this.boId).then((res) => {});

      getProjectDetail(this.boId).then((res) => {
        ;
        this.stage = res.data.stage;
        this.$refs.stepRef.setStage(this.stage);
      });
    },
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return;
        // TODO 提交表单
        downProcurementReady({
          ...this.formData,
          boId: this.boId,
          projectId: this.projectId,
        }).then((res) => {
          this.$message({
            message: "操作成功",
            type: "success",
          });
          this.$router.replace("/purchase/index");
        });
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
  },
};
</script>
<style></style>
